import request from '@/utils/request';

export interface PartyFeeCalculationDTO {
  year: number;
  month?: number;  // 可选，不传则计算全年
}

export interface PartyFeeQueryDTO {
  keyword?: string;    // 搜索关键词
  className?: string;  // 班级筛选
  position?: string;   // 职务筛选
  year?: number;       // 年份筛选
  page?: number;       // 页码
  size?: number;       // 每页条数
}

export interface PartyFee {
  id: number;
  className: string;
  position: string;
  name: string;
  idCard: string;
  identifier: string;
  year: number;
  month: number;
  baseAmount: number;
  partyFee: number;
  remark: string;
}

export interface PartyFeeQueryResult {
  records: PartyFee[];
  total: number;
}

// 计算党费
export const calculatePartyFees = (data: PartyFeeCalculationDTO) => {
  return request.post('/party-fees/calculate', data);
};

// 获取党费列表
export const getPartyFees = (params: PartyFeeQueryDTO) => {
  return request.get<PartyFeeQueryResult>('/party-fees', { params });
};

// 导出党费数据
export const exportPartyFees = (params: PartyFeeQueryDTO) => {
  return request.get('/party-fees/export', {
    params,
    responseType: 'blob',
  });
}; 